﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DAO
{
    public class CommentDAO
    {
        private FDeal4Entities db;

        public CommentDAO()
        {
            db = new FDeal4Entities();
        }

       public List<COMMENT> LietKe()
        {
            return db.COMMENT.ToList();
        }

        public COMMENT LayID(string id)
        {
            var tl = db.COMMENT.SingleOrDefault(t => t.IDCOMMENT == id);
            return tl;
        }

        public bool Them(COMMENT tl)
        {
            try
            {
                db.COMMENT.AddObject(tl);
                db.SaveChanges();
                return true;
            }
            catch (System.Exception ex)
            {
                return false;
            }
        }

        public bool Xoa(COMMENT tl)
        {
            try
            {
                db.COMMENT.DeleteObject(tl);
                db.SaveChanges();
                return true;
            }
            catch (System.Exception ex)
            {
                return false;
            }
        }
    }
}
